<template>
  <div id="app">
    <!-- 页面 -->
    <transition name='page' mode="out-in" >
      <router-view/>
    </transition>
    <!-- 底部菜单 -->
    <MenuB v-if="menuShow" :chose="menuChose"></MenuB>
    <!-- 弹层 -->
    <ScorePop :scoreShow="scoreShow" :scoreText="scoreText" :scoreNum="scoreNum" @scoreClose="scoreClose"></ScorePop>
    <!-- 提示弹窗 -->
    <Popup v-show="popupShow" :popupShow="popupShow" :popupType="popupType" :popupText="popupText" :popupTips="popupTips" @popupCancel="popupCancel" @popupSure="popupSure"></Popup>
	<!-- 新手引导 -->
    <Guide v-if="guideShow" :guideShow="guideShow" @guideClose="guideClose"></Guide>
	
  </div>
</template>

<script>
import { axGet,axPost } from '@/api/index'
import MenuB from './components/MenuBottom'
import ScorePop from './components/PopupScore'
import Popup from './components/Popup'
import Guide from './components/Guide'


export default {
	name: 'App',
	components: { 
		MenuB,
		ScorePop,
		Popup,
		Guide,
	},
	data(){
		return{
			headError:'this.src="' + require('@/assets/img/no-head.png') + '"',//默认头像
			myInfo:sessionStorage.getItem("myInfo") ? JSON.parse(sessionStorage.getItem("myInfo")):{},//用户信息
			menuShow:false, //是否显示底部菜单
			menuChose:1,    //当前菜单
			menuFirst:true,

			scoreShow:false,
			scoreText:'',
			scoreNum:0,
			scoreType:0,

			// hasGuide:false,
			guideShow:false,
			
			//提示弹窗
			popupShow:false,
			popupType:2,
			popupText:'',
			popupTips:'',
		}
	},
	watch:{
		
	},
	created(){ 
		
	},
	mounted(){
	},
	methods:{
		guideClose(){
			this.guideShow=false
		},
		popupClose(){
			this.popupShow=false
		},
		popupCancel(){
			this.popupShow=false
		},
		popupSure(){
			
		},
		scoreClose(){
			this.scoreShow=false;
			if(this.scoreType==0 || this.scoreType==1){
				// history.go(-1)
				this.$router.go(-1)
			}
		},
		// 积分
		postScore(num,type,text){
			axPost('PostIntegral', {
				userId:this.myInfo.UserId,
				number:num,
				integralType:type, //提交心得0  创建任务1  打卡 2   答题 3     留言4        
			}).then(res => {
				if(res.ResultCode==1 && res.Value){
					this.scoreType=type
					this.scoreText=text
					this.scoreNum=num
					this.scoreShow=true                                          
					sessionStorage.setItem("postScore"+type,'true')
				}else{
					sessionStorage.setItem("postScore"+type,'true')
					if(type==0 || type==1){
						this.$router.go(-1) 
					}else if(type==4){
						this.$LayerTip({
							content:"发送成功",
							time:1500,
						});
					}
				}
			})
		},
	}
}
</script>

<style>
#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
